SuperStrict

Framework BRL.StandardIO

Import Otus.RE2

Local r:TRegEx = TRegEx.Create("Hello.+World")
Local s:Int, l:Int, sa:Int[4], la:Int[4]


Print 0=RegExIsFullMatch("Hello World!", "Hello.+World")
Print 1=RegExIsPartialMatch("Hello World!", "Hello.+World")
Print 1=RegExMatch("Hello World!", "Hello.+World", s, l)
Print 0=s
Print 11=l
Print 1=RegExMatchSub("Hello World!", "(Hello).+(World)", sa, la)
Print 0=sa[0]
Print 5=la[1]
Print 6=sa[2]
Print -1=sa[3]


Print 1=r.IsPartialMatch("Hello World")
Print 1=r.IsPartialMatch("Hello World!")
Print 1=r.IsPartialMatch("Hello --- World")
Print 0=r.IsPartialMatch("HelloWorld")


Print 1=r.IsFullMatch("Hello World")
Print 0=r.IsFullMatch("Hello World!")
Print 1=r.IsFullMatch("Hello --- World")
Print 0=r.IsFullMatch("HelloWorld")


r = TRegEx.Create("World")


Print 1=r.Match("Hello World", s, l)
Print 6=s
Print 5=l


r = TRegEx.Create("(Hello).*(World)")


Print 1=r.MatchSub("Hello World", sa, la)
Print 0=sa[0]
Print 11=la[0]
Print 0=sa[1]
Print 5=la[1]
Print 6=sa[2]
Print 5=la[2]
Print -1=sa[3]


Print "Looking for memory leaks..."


For Local j:Int = 1 To 10
For Local i:Int = 1 To 10000
	Local r2:TRegEx = TRegEx.Create("blah.*")
	Local s:Int, l:Int
	r2.Match("blah blah", s, l)
Next
Print j
Next


Print "done"
